﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using FTchina;

public partial class UI_Cache : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        basic.CheckAdmin(this);
        basic.ChkPoewr(this, FTchina.Api.htmlpath.GetCurrentPagePath());
        getaspnetn();
        GetCacheCount();
        GetAllCache();

    }
    /// <summary>
    /// 获取当前的ASP.NET进程占用内存
    /// </summary>
    /// <returns></returns>
    private void getaspnetn()
    {
        string temp;
        try
        {
            temp = ((Double)System.Diagnostics.Process.GetCurrentProcess().WorkingSet / 1048576).ToString("N2");
        }
        catch
        {
            temp = "未知";
        }
        lblnc.Text = temp;
    }

    private void GetCacheCount()
    {
        lblcachecount.Text = HttpContext.Current.Cache.Count.ToString();
    }
    protected void btnClear_Click(object sender, EventArgs e)
    {
        FTchina.Caching.FTchinaCache.RemoveAllCache();
        GetCacheCount();
        GetAllCache();
        getaspnetn();
    }
    protected void GetAllCache()
    {
        litlist.Text = "";
        System.Collections.IDictionaryEnumerator ss = HttpContext.Current.Cache.GetEnumerator();


        while (ss.MoveNext())
        {

            litlist.Text += "    <tr><td><font color=blue>[" + ss.Value.GetType() + "]</font><font color=green>" + FTchina.basic.GetSubString(ss.Key.ToString(), 20) + "</font></td><td>" + FTchina.basic.GetSubString(FTchina.basic.ForTXT(ss.Value.ToString()), 50, "……") + "</td></tr>";

        }

    }




    protected void btnUnload_Click(object sender, EventArgs e)
    {
        try
        {//终止当前应用程序，在下次接收到请求时重新启动

            HttpRuntime.UnloadAppDomain();
        }
        catch
        {//如果失败了就动webc.onfig的最后修改时间属性。
            string WebConfigPath = HttpContext.Current.Request.PhysicalApplicationPath + "\\Web.config";
            System.IO.File.SetLastWriteTimeUtc(WebConfigPath, DateTime.UtcNow);

        }
    }
    protected void btnrebuildhome_Click(object sender, EventArgs e)
    {
        
    }
    protected void btnrebuildlist_Click(object sender, EventArgs e)
    {
        
    }
}
